﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Entity;
using System.Web.Services;
using System.Collections;
namespace Web.admin.CompetitionManage.Phases
{
    public partial class ListPhases : System.Web.UI.Page
    {
        PhaseService phaseService = new PhaseService();
        const int pagesize = 10;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Rp_Bind();
            }
        }

        /// <summary>
        /// repeater控件绑定
        /// </summary>
        protected void Rp_Bind()
        {
            Pager1.PageSize = pagesize;
            int records = 0;
            Repeater1.DataSource = phaseService.getPagePhases("", " PHA_ID DESC", Pager1.PageSize, Pager1.PageIndex, out records);
            Repeater1.DataBind();
            //初始化分页条,设置样式
            Pager1.SetPage(records);
            Pager1.ShowPageJump = true;
            Pager1.ShowPageLan = 0; //导航条语言:0=默认，1=中文，2=英语
        }
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int j = 0;
            for (int i = 0; i < Repeater1.Items.Count; i++)
            {
                string id = ((HiddenField)Repeater1.Items[i].FindControl("PhaseID")).Value;
                CheckBox cb = (CheckBox)Repeater1.Items[i].FindControl("chkbx");
                if (cb.Checked)
                {
                    
                    BoPhases Phases = new BoPhases();
                    Phases.PHA_ID = id;
                    phaseService.DeletePhase(Phases);
                    j++;
                }
            }
            Response.Write("<script>alert('删除成功，共删除" + j + "条数据');window.location.href='ListPhases.aspx'; </script>");
            return;
        }
    }
}